/*
 *  TimeController.h
 *  SoundController0002
 *
 *  Created by jiro on 10/09/05.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#pragma once

namespace sc
{

	class TimeController 
	{
	public:
		enum 
		{
			SecondsPerMinute = 60
		};

		enum NoteLengthType
		{
			WholeNote,

			HalfNote,
			
			QuarterNote,
			
			EighthNote,
			
			SixteenthNote,
			
			ThirtySecondNote,


			WholeNoteDotted,

			HalfNoteDotted,
			
			QuarterNoteDotted,
			
			EighthNoteDotted,
			
			SixteenthNoteDotted,
			
			ThirtySecondNoteDotted,


			WholeNoteTriplet,

			HalfNoteTriplet,
			
			QuarterNoteTriplet,
			
			EighthNoteTriplet,
			
			SixteenthNoteTriplet,
			
			ThirtySecondNoteTriplet,

		};

	private:

		double beatsPerMinute;
		
		double beatNumerator;
		
		double beatFraction;

	public:

		TimeController( double beatsPerMiniute, double beatNumerator, double beatFraction );

		void SetTempo( double beatsPerMiniute );

		double GetSecondsPerBar() const;

		double GetSecondsToBarCount( int barCount ) const;

		double GetSecondsPerBeat() const;

		double GetTempoSwell() const;

		double GetNoteSeconds( NoteLengthType noteLengthType ) const;

		/** @brief set reference note length, 
			@param type reference beat length
			@param beatCount beat count in reference beat length	*/
		double GetNoteSeconds( NoteLengthType type, int beatCount ) const;

		double GetNoteSwell( NoteLengthType noteLengthType ) const;
	};
}
